package edu.lingnan.springcloud.service;

import edu.lingnan.springcloud.entity.Classes;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author wuyuan
 * @since 2020-06-09 21:31
 * 降级 ~
 */
@Component
public class ClassesClientServiceFallbackFactory implements FallbackFactory<ClassesClientService> {
    @Override
    public ClassesClientService create(Throwable throwable) {
        return new ClassesClientService(){

            @Override
            public List<Classes> queryAll() {
                return null;
            }

            @Override
            public Classes selectById(int id) {
                return new Classes()
                        .setId(id)
                        .setName("id --> " + id + "没有对应数据，" + "客户端提供了服务降级信息，这个服务已将关闭！")
                        .setDatabase("database is not found!");
            }
        };
    }
}
